package com.my.library.entity;

import java.sql.Date;
import java.sql.Timestamp;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;

import org.codehaus.jackson.annotate.JsonBackReference;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonManagedReference;
import org.junit.Ignore;

@SuppressWarnings("serial")
@Entity
public class Book extends BaseModel {
	private int id;
	private String name;
	private Date borrowTime;
	private Timestamp returnTime;
	private String kind;// 类型:chinese or foreign
	
	//@JsonIgnore
	private User user;
	/**
	 * @return the user
	 */
	@ManyToOne(fetch=FetchType.EAGER)
//	@JsonBackReference
	@JsonManagedReference
	//@JsonIgnore
	public User getUser() {
		return user;
	}
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "Book [id=" + id + ", name=" + name + ", borrowTime="
				+ borrowTime + ", returnTime=" + returnTime + ", kind=" + kind
				+ ", user=" + user + "]";
	}
	/**
	 * @param user the user to set
	 */
	public void setUser(User user) {
		this.user = user;
	}
	/**
	 * @return the id
	 */
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public int getId() {
		return id;
	}
	/**
	 * @param id the id to set
	 */
	public void setId(int id) {
		this.id = id;
	}
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * @return the borrowTime
	 */
	public Date getBorrowTime() {
		return borrowTime;
	}
	/**
	 * @param borrowTime the borrowTime to set
	 */
	public void setBorrowTime(Date borrowTime) {
		this.borrowTime = borrowTime;
	}
	/**
	 * @return the kind
	 */
	public String getKind() {
		return kind;
	}
	/**
	 * @param kind the kind to set
	 */
	public void setKind(String kind) {
		this.kind = kind;
	}
	/**
	 * @return the returnTime
	 */
	public Timestamp getReturnTime() {
		return returnTime;
	}
	/**
	 * @param returnTime the returnTime to set
	 */
	public void setReturnTime(Timestamp returnTime) {
		this.returnTime = returnTime;
	}
}
